﻿<Window xmlns:my="clr-namespace:WgpgGUI"
        xmlns:core="clr-namespace:WgpgCore;assembly=WgpgCore"
        x:Class="WgpgGUI.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Wgpg - Key Manager"
        SnapsToDevicePixels="True"
        Width="{Binding Source={x:Static core:Config.Instance}, Path=MainWindowWidth, Mode=TwoWay}"
        Height="{Binding Source={x:Static core:Config.Instance}, Path=MainWindowHeight, Mode=TwoWay}"
        Left="{Binding Source={x:Static core:Config.Instance}, Path=MainWindowLeft, Mode=TwoWay}"
        Top="{Binding Source={x:Static core:Config.Instance}, Path=MainWindowTop, Mode=TwoWay}">

    <Window.InputBindings>
        <KeyBinding Key="D" Modifiers="Control" Command="{x:Static my:MainWindow.DecryptFileCommand}"/>
        <KeyBinding Key="E" Modifiers="Control" Command="{x:Static my:MainWindow.EncryptFileCommand}"/>
        <KeyBinding Key="Enter" Command="{x:Static my:MainWindow.OpenKeyInformationCommand}"/>
    </Window.InputBindings>

    <Window.CommandBindings>
        <CommandBinding Command="New" CanExecute="GenerateKey_CanExecute" Executed="GenerateKey_Executed" />
        <CommandBinding Command="Delete" CanExecute="DeleteKey_CanExecute" Executed="DeleteKey_Executed"/>
        <CommandBinding Command="Refresh" CanExecute="Refresh_CanExecute" Executed="Refresh_Executed"/>
        <CommandBinding Command="{x:Static my:MainWindow.OpenKeyInformationCommand}" CanExecute="OpenKeyInformation_CanExecute" Executed="OpenKeyInformation_Executed"/>
        <CommandBinding Command="{x:Static my:MainWindow.OpenTaskListCommand}" CanExecute="OpenTaskList_CanExecute" Executed="OpenTaskList_Executed"/>
        <CommandBinding Command="{x:Static my:MainWindow.AboutWgpgCommand}" CanExecute="AboutWgpg_CanExecute" Executed="AboutWgpg_Executed"/>
        <CommandBinding Command="{x:Static my:MainWindow.DecryptFileCommand}" CanExecute="DecryptFile_CanExecute" Executed="DecryptFile_Executed"/>
        <CommandBinding Command="{x:Static my:MainWindow.EncryptFileCommand}" CanExecute="EncryptFile_CanExecute" Executed="EncryptFile_Executed"/>
        <CommandBinding Command="{x:Static my:MainWindow.SignFileCommand}" CanExecute="SignFile_CanExecute" Executed="SignFile_Executed"/>
        <CommandBinding Command="{x:Static my:MainWindow.VerifyFileCommand}" CanExecute="VerifyFile_CanExecute" Executed="VerifyFile_Executed"/>
        <CommandBinding Command="{x:Static my:MainWindow.ExportKeyToFileCommand}" CanExecute="ExportKeyToFile_CanExecute" Executed="ExportKeyToFile_Executed"/>
        <CommandBinding Command="{x:Static my:MainWindow.ExportKeyToClipboardCommand}" CanExecute="ExportKeyToClipboard_CanExecute" Executed="ExportKeyToClipboard_Executed"/>
        <CommandBinding Command="{x:Static my:MainWindow.ImportKeyFromFileCommand}" CanExecute="ImportKeyFromFile_CanExecute" Executed="ImportKeyFromFile_Executed"/>
        <CommandBinding Command="{x:Static my:MainWindow.ExportPrivateKeyToClipboardCommand}" CanExecute="ExportPrivateKeyToClipboard_CanExecute" Executed="ExportPrivateKeyToClipboard_Executed"/>
        <CommandBinding Command="{x:Static my:MainWindow.OpenEditorCommand}" CanExecute="OpenEditor_CanExecute" Executed="OpenEditor_Executed"/>
    </Window.CommandBindings>

    <DockPanel>
        <Menu DockPanel.Dock="Top">
            <MenuItem Header="File">
                <MenuItem Header="Open Task List" Command="{x:Static my:MainWindow.OpenTaskListCommand}"/>
                <Separator/>
                <MenuItem Header="Generate a new key" Command="New">
                    <MenuItem.Icon>
                        <my:AutoGreyableImage Source="/WgpgCore;component/Images/newkey.png" Width="16" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator/>
                <MenuItem Header="Encrypt a File" Command="{x:Static my:MainWindow.EncryptFileCommand}" InputGestureText="Ctrl+E">
                    <MenuItem.Icon>
                        <my:AutoGreyableImage Source="/WgpgCore;component/Images/encrypt_16.png" Width="16" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="Decrypt a File" Command="{x:Static my:MainWindow.DecryptFileCommand}" InputGestureText="Ctrl+D">
                    <MenuItem.Icon>
                        <my:AutoGreyableImage Source="/WgpgCore;component/Images/decrypt_16.png" Width="16" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator/>
                <MenuItem Header="Sign a File" Command="{x:Static my:MainWindow.SignFileCommand}">
                </MenuItem>
                <MenuItem Header="Verify a File" Command="{x:Static my:MainWindow.VerifyFileCommand}">
                </MenuItem>
                <Separator/>
                <MenuItem Header="Exit" InputGestureText="Alt+F4" />
            </MenuItem>
            <MenuItem Header="Edit">
                <MenuItem Header="Refresh" Command="Refresh">
                    <MenuItem.Icon>
                        <my:AutoGreyableImage Source="/WgpgCore;component/Images/refresh.png" Width="16" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator/>
                <MenuItem Header="View Key Information" Command="{x:Static my:MainWindow.OpenKeyInformationCommand}" InputGestureText="Enter">
                    <MenuItem.Icon>
                        <my:AutoGreyableImage Source="/WgpgCore;component/Images/keyproperty1.png" Width="16"/>
                    </MenuItem.Icon>
                </MenuItem>
                <Separator/>
                <MenuItem Header="Export Key">
                    <MenuItem Header="Export key to File" Command="{x:Static my:MainWindow.ExportKeyToFileCommand}">
                        <MenuItem.Icon>
                            <my:AutoGreyableImage Source="/WgpgCore;component/Images/export_key_16.png" Width="16" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="Export key to Clipboard" Command="{x:Static my:MainWindow.ExportKeyToClipboardCommand}">
                        <MenuItem.Icon>
                            <my:AutoGreyableImage Source="/WgpgCore;component/Images/export_key_16.png" Width="16" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator/>
                    <MenuItem Header="Export private key to Clipboard" Command="{x:Static my:MainWindow.ExportPrivateKeyToClipboardCommand}">
                        <MenuItem.Icon>
                            <my:AutoGreyableImage Source="/WgpgCore;component/Images/export_key_16.png" Width="16" />
                        </MenuItem.Icon>
                    </MenuItem>
                </MenuItem>
                <Separator/>
                <MenuItem Header="Import key from File" Command="{x:Static my:MainWindow.ImportKeyFromFileCommand}"/>
                <Separator/>
                <MenuItem Header="Delete selected key" Command="Delete">
                    <MenuItem.Icon>
                        <my:AutoGreyableImage Source="/WgpgCore;component/Images/delete_key_16.png" Width="16" />
                    </MenuItem.Icon>
                </MenuItem>
            </MenuItem>
            <MenuItem Header="Tools">
                <MenuItem Header="Editor..." Command="{x:Static my:MainWindow.OpenEditorCommand}"/>
            </MenuItem>
            <MenuItem Header="?">
                <MenuItem Header="About Wgpg" Command="{x:Static my:MainWindow.AboutWgpgCommand}"/>
            </MenuItem>
        </Menu>
        
        <ToolBarTray DockPanel.Dock="Top">
            <ToolBar Band="1" BandIndex="1">
                <Button ToolTip="Generate a new key" Command="New">
                    <my:AutoGreyableImage Source="/WgpgCore;component/Images/newkey.png" Width="16"/>
                </Button>
                <Button ToolTip="Encrypt a File" Command="{x:Static my:MainWindow.EncryptFileCommand}">
                    <my:AutoGreyableImage Source="/WgpgCore;component/Images/encrypt_16.png" Width="16"/>
                </Button>
                <Button ToolTip="Decrypt a File" Command="{x:Static my:MainWindow.DecryptFileCommand}">
                    <my:AutoGreyableImage Source="/WgpgCore;component/Images/decrypt_16.png" Width="16"/>
                </Button>
            </ToolBar>
            <ToolBar Band="1" BandIndex="2">
                <Button ToolTip="View Key Information" Command="{x:Static my:MainWindow.OpenKeyInformationCommand}">
                    <my:AutoGreyableImage Source="/WgpgCore;component/Images/keyproperty1.png" Width="16"/>
                </Button>
                <Separator/>
                <Button ToolTip="Export Key to File" Command="{x:Static my:MainWindow.ExportKeyToFileCommand}">
                    <my:AutoGreyableImage Source="/WgpgCore;component/Images/export_key_16.png" Width="16" />
                </Button>
                <Button ToolTip="Export Key to Clipboard" Command="{x:Static my:MainWindow.ExportKeyToClipboardCommand}">
                    <my:AutoGreyableImage Source="/WgpgCore;component/Images/export_key_16.png" Width="16" />
                </Button>
                <Separator/>
                <Button ToolTip="Delete selected key" Command="Delete">
                    <my:AutoGreyableImage Source="/WgpgCore;component/Images/delete_key_16.png" Width="16" />
                </Button>
            </ToolBar>
            <ToolBar Band="1" BandIndex="3">
                <my:SearchTextBox Width="150" x:Name="searchFilter" Search="Search" SearchEventTimeDelay="00:00:00.0"/>
            </ToolBar>
        </ToolBarTray>
        
        <StatusBar DockPanel.Dock="Bottom" VerticalAlignment="Stretch" Background="#F0F0F0" Name="statusBar">
            <StackPanel Name="ready_panel">
                <TextBlock>Ready</TextBlock>
            </StackPanel>
            <StatusBarItem VerticalAlignment="Center" Name="StatusBar_Progress" Visibility="Collapsed">
                <StackPanel Orientation="Horizontal">
                    <ProgressBar Height="16" Width="100" IsIndeterminate="True"/>
                    <Button Width="19" Height="16" Padding="0" Margin="10 0 0 0" ToolTip="Open Tasks" MinWidth="0" Command="{x:Static my:MainWindow.OpenTaskListCommand}">
                        <Image Width="13" Height="13" Source="/WgpgCore;component/Images/arrow_up.png"/>
                    </Button>
                </StackPanel>
            </StatusBarItem>
        </StatusBar>

        <Grid DockPanel.Dock="Bottom">
            <ListView BorderThickness="0 1 0 1" Name="keylistview" PreviewMouseDoubleClick="ListViewDoubleClick" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch" ItemsSource="{Binding}" ItemContainerStyle="{StaticResource KeyListViewItem}" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                <ListView.GroupStyle>
                    <GroupStyle ContainerStyle="{StaticResource KeyListViewGroups}"/>
                </ListView.GroupStyle>
            </ListView>
        </Grid>
    </DockPanel>
</Window>
